﻿// -----------------------------------------------------------------------
// <copyright file="ObjectDisplay.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Cubezicles.UI
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;
    using Microsoft.Xna.Framework.Input;

    // todo: make a similar display for an object/item that is currently selected in the 3d world???

    /// <summary>
    /// Manages the display of the needs for the currently selected employee
    /// </summary>
    public class ObjectDisplay : DrawableGameComponent
    {
        // Texture that we'll stretch out and re-color to display the NeedsMeter.
        private Texture2D dot;

        // Texture for the interface background and mood
        private Texture2D bg, mood;

        //Texture for buttons
        Texture2D btn_btw;

        // - Parameters for drawing lines of text
        private float StatusX; // Set in draw

        // the height of a line in pixels
        private const int LineHeight = 20;

        // Current Employee format
        //const string employeeFormat = "Current Employee: {0}";

        // Get the active employee from the Game1
        private PlaceableGameComponent obj { get { return game1.CurrentSelectedObject; } }

        // Get the Game1 object stored by the base class
        private Game1 game1 { get { return (Game1)Game; } }

        public ObjectDisplay(Game1 game) : base(game) { this.DrawOrder = (int)Game1.DisplayOrder.UI; }

        protected override void LoadContent()
        {
            dot = Game.Content.Load<Texture2D>("Textures/dot");
            bg = Game.Content.Load<Texture2D>("UI/workerstatbg");
           // mood = Game.Content.Load<Texture2D>("UI/mood");
            btn_btw = Game.Content.Load<Texture2D>("UI/btn_btw");
            base.LoadContent();
        }
        
        //UI.Control control;
        public override void Draw(GameTime gameTime)
        {
            // Get the screen width and height
            int screenH = game1.screenH;
            int screenW = game1.screenW;

            StatusX = screenW - bg.Width + 35;
           // MeterX = StatusX + 80;

            // If no object is selected, this component does nothing
            if (obj == null)
            {
                return;
            }

            game1.SpriteBatch.Begin();

            // The line (from bottom of screen) to start writing at
            float currY = screenH - 160; // mmmm, curry 

            // Draw the background
            game1.SpriteBatch.Draw(bg, new Vector2(screenW - bg.Width, currY), Color.White);



            // Use the colors calculated by the employee's overallMood
            // to determine the background color for the avatar profile pic thingy
           // game1.SpriteBatch.Draw(mood, new Vector2(screenW - mood.Width, currY - 5), determineColor(emp.OverallMood));

            // Display the name of the object
            
            string objName = game1.CurrentSelectedObject.name;
            game1.SpriteBatch.DrawString(game1.Fonts["status"], objName,
            new Vector2(screenW - 75, screenH - 80), Color.White);

            currY += LineHeight;

            // Display the need that this object fulfills


            currY += LineHeight;

            // Display the tagline for this object
            string objDesc = game1.CurrentSelectedObject.tagline;
            game1.SpriteBatch.DrawString(game1.Fonts["status"], objName,
            new Vector2(screenW - 75, screenH - 80), Color.White);
            currY += LineHeight;

            // Display the original cost for this object
            string objPrice = game1.CurrentSelectedObject.price.ToString();
            game1.SpriteBatch.DrawString(game1.Fonts["status"], objName,
            new Vector2(screenW - 75, screenH - 80), Color.White);
            currY += LineHeight;

            

            //currY += LineHeight;
            currY += 2;
            //currY = DrawNeed(emp.MoodLevels.hunger, "Hunger", currY);
            //currY = DrawNeed(emp.MoodLevels.fun, "Fun", currY);
            //currY = DrawNeed(emp.MoodLevels.energy, "Energy", currY);
            //currY = DrawNeed(emp.MoodLevels.bladder, "Bladder", currY);
            //currY = DrawNeed(emp.MoodLevels.focus, "Focus", currY);
            int x = 10;

           

            // Draw Status
            //var statusString = "Status: " + game1.CurrentEmployee.GetStateString();
            //game1.SpriteBatch.DrawString(game1.Fonts["status"], statusString,
            //new Vector2(screenW - game1.Fonts["status"].MeasureString(statusString).X - x, screenH - 50), game1.UIblue);
            //^'s a good example of right aligned text.
            
            game1.SpriteBatch.End();
            base.Draw(gameTime);
        }
        

       /* private float DrawObjectInfo(float need, string needName, float y)
        {
            var statNameStart = new Vector2(StatusX, y);

            // Rectangle outlining the health meter.
            var meterRect = new Rectangle((int)MeterX, (int)(y + MeterOffset),
                                          (int)(100 * need), (int)MeterHeight);


            // Show needs in red if their levels are "critical"
            // var color = need > 0.2 ? Color.Green : Color.Red;

            var color = Color.LavenderBlush; // random//determineColor(need);

            game1.SpriteBatch.DrawString(game1.Fonts["needs"], needName + ": ", statNameStart, color);
            game1.SpriteBatch.Draw(dot, meterRect, color);

            return y + LineHeight;
        }
        */

    }
}
